package xyf.p11.other.bit;

/**
 * ClassName: P0461_HanMingDistance
 * Description:
 * Author: xyf
 * Date: 9/8/22 8:40 PM
 * Version: 1.0
 **/
public class P0461_HanMingDistance
{
    public int hammingDistance(int x, int y)
    {
        int tmp = x ^ y;
        int base = 1;
        int res = 0;
        for (int i = 0; i < 31; i++)
        {
            if ((base & tmp) != 0)
            {
                res++;
            }
            base *= 2;
        }
        return res;
    }
}